﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Net
{
    /// <summary>
    /// 记录发送数据时发生的错误、异常、反馈信息等
    /// </summary>
    public class sendLog
    {
        public bool end;

        private sendLog()
        {
            log = new List<string>();
        }

        static private sendLog instance;

        public static sendLog Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new sendLog();
                }
                return instance;
            }

        }
        private List<string> log;

        public List<string> Log
        {
            get { return log; }
            set { log = value; }
        }
        private int progressValue;

        public int ProgressValue
        {
            get { return progressValue; }
            set { progressValue = value; }
        }

        private int oneStepValue;
        /// <summary>
        /// 每一个写入信息占总过程的百分比值
        /// </summary>
        public int OneStepValue
        {
            get { return oneStepValue; }
            set { oneStepValue = value; }
        }

        public void addStep()
        {
            if (progressValue + oneStepValue > 100)
                progressValue = 100;
            else
            {
                progressValue += oneStepValue;
            }
            log.Add("\r\n\r\n******************************");
        }

        public void over()
        {
            progressValue = 100;
        }

        public override string ToString()
        {
            string returnStr = "";
            for (int i = 0; i < log.Count; i++)
            {
                returnStr += log[i] + "\r\n";
            }
            Console.Write(returnStr);
            return returnStr;
        }
    }

}
